package com.jwdf.uda.ui.adapter.item;

import com.jwdf.uda.bean.ExtraBaseQuestion;
import com.jwdf.uda.bean.PbBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/9/18.
 */
public class ReplyDetailItem {
    public static final int TYPE_REPLY_MAIN = 0;
    public static final int TYPE_REPLY_DESC_TXT = 1;
    public static final int TYPE_REPLY_DESC_IMAGE = 2;
    public static final int TYPE_REPLY_CREATE_TIME = 3;
    public static final int TYPE_REPLY_LIKE_SECTION = 4;
    public static final int TYPE_REPLY_USER_LIKE = 5;
    //    public static final int TYPE_TITLE_TAB = 5;
    public static final int TYPE_COMMENT_TXT = 6;
    public static final int TYPE_COMMENT_IMAGE = 7;
//    public static final int TYPE_LIKE = 8;

    public int itemType;
    public int likeCount;
    public int commentCount;

    public PbBean.PbUserSimple userInfo;
    public String quizTitle;
    public int questionId;
    public boolean isFollowed;
    public int answerId;
    public ExtraBaseQuestion extraBaseQuestion;
    public PbBean.PbSignBaseVoteOptionType voteOptionType;
    public String answerDescTxt;
    public String answerDescImage;
    public int imageIndex;
    public ArrayList<String> imageUrls;
    public int imageWidth;
    public int imageHeight;
    public int createTime;
    public List<PbBean.PbBaseResDescription> descInfo;
    public PbBean.PbUserSimple likeInfo;
    public List<PbBean.PbUserSimple> likeInfos;
    public ReplyDetailItem.ReplyTab currentTab = ReplyTab.COMMENT;

    public PbBean.PbBaseComment comment;
    public int commentId;
    public boolean isLikeComment;
    public int commentLikeCount;

    public ReplyDetailItem(int itemType) {
        this.itemType = itemType;
    }

    public ReplyDetailItem(PbBean.PbBaseComment comment, int itemType) {
        this.comment = comment;
        this.itemType = itemType;
    }

    public ReplyDetailItem(PbBean.PbBaseComment comment, int commentId, boolean isLikeComment, int commentLikeCount) {
        this.comment = comment;
        this.commentId = commentId;
        this.isLikeComment = isLikeComment;
        this.commentLikeCount = commentLikeCount;
    }

    public static ReplyDetailItem convert(PbBean.PbBaseComment comment) {
        ReplyDetailItem item = new ReplyDetailItem(comment, comment.getId(), comment.getIsLike(), comment.getLikeCount());
        return item;
    }

    public static ReplyDetailItem convert(PbBean.PbBaseComment comment, int itemType) {
        ReplyDetailItem item = new ReplyDetailItem(comment, itemType);
        return item;
    }

    public static List<ReplyDetailItem> convert(List<PbBean.PbBaseComment> comments) {
        List<ReplyDetailItem> items = new ArrayList<>();
        if (comments != null) {
            for (int i = 0; i < comments.size(); i++) {
                items.add(convert(comments.get(i)));
            }
        }
        return items;
    }

    public enum ReplyTab {
        COMMENT, LIKE
    }
}
